
const fs = require('fs')
const path = require('path')
/**
 * 下载
 */
const download = (ctx: any,url: string, filename: string) => {
  
  const filePath = '/path/to/download/file.txt';
  const fileName = 'file.txt';
  
  // 创建一个可读流
  const stream = fs.createReadStream(filePath);
  
  // 设置响应头
  ctx.attachment(fileName);
  ctx.type = 'application/octet-stream';
  
  // 写入响应数据
  ctx.body = stream;
}